package ru.evga.gwt.lib.common.client.ui.dialog;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;

/**
 * Edit view for CityProxy.
 */
public class EditButtonBar extends Composite
{

    interface Binder extends UiBinder<HTMLPanel, EditButtonBar>
    {
    }

    private static final Binder BINDER = GWT.create(Binder.class);

    public interface Presenter
    {
        void saveClicked();

        void cancelClicked();
    }

    @UiField
    Button m_save;
    @UiField
    Button m_cancel;

    private Presenter m_presenter;

    public EditButtonBar()
    {
        initWidget(BINDER.createAndBindUi(this));
    }

    public void setPresenter(Presenter presenter)
    {
        m_presenter = presenter;
    }

    @UiHandler("m_save")
    void saveClick(ClickEvent event)
    {
        if (m_presenter != null)
        {
            m_presenter.saveClicked();
        }
    }

    @UiHandler("m_cancel")
    void cancelClick(ClickEvent event)
    {
        if (m_presenter != null)
        {
            m_presenter.cancelClicked();
        }
    }

}
